#!/usr/bin/python
# -*- coding: UTF-8 -*-
__author__ = 'dengqianyi'


#!/usr/bin/env python

from tornado.tcpserver import TCPServer
from tornado.ioloop  import IOLoop
import tornado.autoreload

#our lib
import mainHelp

g_IOLoop = IOLoop.instance()

class myTcpServer(TCPServer):
    # _connection = dict()
    def handle_stream(self, stream, address):
        #增加到里面
        mainHelp.Connection(stream,address)

def getGlobalIOLoop():
    global g_IOLoop
    return g_IOLoop

if __name__ == '__main__':
    print "main begin ..."
    mainHelp.allInit()
    server = myTcpServer()
    server.listen(8000)
    tornado.autoreload.start(g_IOLoop)
    g_IOLoop.start()